package com.seanLab.web;

import com.seanLab.domain.Body;
import com.seanLab.dto.EditorArticleDto;
import com.seanLab.dto.RecommendArticleDto;
import com.seanLab.service.ImageService;
import com.seanLab.service.RecommendService;
import com.seanLab.tool.TagSuggestModel.ExpandRank.common.AnsjSegment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

/**
 * 配图推荐接口，主要为recommendImages
 * Created by ailly on 17-9-21.
 */
@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
@RequestMapping("/v1/images")
public class RecommendController {
    @Autowired
    private RecommendService recommendService;

    @RequestMapping(path = "/queries", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
    public Body recommendImages(@RequestBody RecommendArticleDto recommendArticleDto) {
        Body body = this.recommendService.recommendImages(recommendArticleDto);
        return body;
    }

    /**
     * 测试分词结果
     * @param recommendArticleDto
     * @return
     */
    @RequestMapping(path = "/segment", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
    public String testSegment(@RequestBody RecommendArticleDto recommendArticleDto) {
        return new AnsjSegment().segmentToString(recommendArticleDto.getTitle() + " " + recommendArticleDto.getContent());
    }

}
